#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QtGui>
#include "Prerequisites.hpp"

#include "Debug/LogManager.h"

#include "Computer/realmachine.h"
#include "OS/os.h"
#include "OS/planner.h"
#include "OS/resourceallocator.h"
#include "Resources/programloadingbuffer.h"

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

    enum IOStates {
        CONSOLE,
        READ_WORD,
        READ_BLOCK,
        WRITE_WORD,
        WRITE_BLOCK,
        STOP
    };
private:
    IOStates iostate;
    String iobuffer;

    QStandardItemModel *rmemModel;
    QStandardItemModel *vmemModel;
    QStandardItemModel *smemModel;

    QStandardItemModel *processModel;
    QStandardItemModel *resourceModel;

    void PrintHelp(void);

    int CurrentMemType;
    void UpdateMemView();
    void ShowVirtualMem();
    void ShowRealMem();
    void ShowSharedMem();
    int LoadProgram(String rFileName, WordVector *rOutput);
    void UpdateRegisterView();
    void Step(void);
    int runType;

    void updateProcessList();
    void updateResourceList();

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

    LogManager* logManager;

    RealMachine* realMachine;
    OS* operatingSystem;
    
private slots:
    void on_listView_activated(const QModelIndex &index);

    void on_send_clicked();

    void on_in_returnPressed();

    void processUserInput(void);

    void on_pushButton_clicked();

    void on_pushButton_2_clicked();

private:
    Ui::MainWindow *ui;
};

#endif // MAINWINDOW_H
